#include "ndame.h"
Go to the source code of this file.
Functions | |
int | attack (struct data *d1, int ii, int ik) |
attack |
Definition in file attack.c.
|
attack This file gets the current position of the chessboard where calculate() wants to set a queen. It checks horizontally, vertically and diagonally whether there a queen. If there is a queen, the programme returns 1 else 0.
Definition at line 25 of file attack.c. References data::iboard. Referenced by calculate(). 00026 { 00027 int irow; 00028 int icol; 00029 00030 irow=ii; //reset board position 00031 icol=ik; //reset board position 00032 00033 for(irow;irow>=0;irow--) //lower 00034 { 00035 if(d1->iboard[irow][icol]) 00036 { 00037 return 1; 00038 } 00039 } 00040 irow=ii; //reset board position 00041 00042 while((irow>=0)&&(icol>=0)) //left lower; 00043 { 00044 if(d1->iboard[irow][icol]) 00045 { 00046 return 1; 00047 } 00048 00049 irow--; 00050 icol--; 00051 } 00052 irow=ii; //reset board position 00053 icol=ik; //reset board position 00054 00055 while((irow>=0)&&(icol<d1->iblength)) //right lower; 00056 { 00057 if(d1->iboard[irow][icol]) 00058 { 00059 return 1; 00060 } 00061 00062 irow--; 00063 icol++; 00064 } 00065 00066 return 0; 00067 }
|